package yxy.game.pm2.module.fortdefeat;

import java.util.ArrayList;
import java.util.Collection;

import yxy.game.pm2.bean.Currency;
import yxy.game.pm2.bean.mq.CCReason;
import yxy.game.pm2.module.CurrencyHandle;
import yxy.game.pm2.module.battle.ISettlement;

/** 过关斩将的战斗结算 */
public class SettlementFortDefeat implements ISettlement {
	// bean===========================================================================

	private String playerCode;
	private ArrayList<Currency> rewards = new ArrayList<>();
	private int mapId;

	public String getPlayerCode() {
		return playerCode;
	}

	public void setPlayerCode(String playerCode) {
		this.playerCode = playerCode;
	}

	public ArrayList<Currency> getRewards() {
		return rewards;
	}

	public void setRewards(ArrayList<Currency> rewards) {
		this.rewards = rewards;
	}

	public int getMapId() {
		return mapId;
	}

	public void setMapId(int mapId) {
		this.mapId = mapId;
	}
	// func===========================================================================

	@Override
	public void settle() {
		new CurrencyHandle().addCurrency(playerCode, CCReason.过关斩将, getRewards());
		new FortDefeatHandle().nextMap(getPlayerCode(), getMapId(), getRewards());
	}

	@Override
	public Collection<Currency> reward() {
		return getRewards();
	}

	static public SettlementFortDefeat create(String playerCode, int mapId) {
		SettlementFortDefeat settlement = new SettlementFortDefeat();
		try {
			settlement.setPlayerCode(playerCode);
			settlement.setMapId(mapId);
			settlement.setRewards(new ArrayList<>(FortDefeatHandle.mapReward(mapId)));

			return settlement;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

}
